home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Tools / PostRez.a < prev    next >
Encoding:
Text File  |  1990-10-25  |  2.0 KB  |  90 lines  |  [TEXT/MPS ]

  1. ; Copyright © 1984-1990 Apple Computer, Inc.  All rights reserved.
  2.  
  3.                 Blanks        On
  4.                 String        AsIs
  5.                 Case        On
  6.  
  7.                 Print        Off
  8.                 Include     'Macros.a'
  9.                 Include     'Traps.a'
  10.  
  11.                 LOAD            'ProgStrucMacs.d'
  12.                 LOAD            'FlowCtlMacs.d'
  13.                 Print        On
  14.             
  15.  
  16. ;-------------------------------------------------------------------
  17. ; Procedure ConvertToMenu(cmnuHandle: Handle; menuID: integer; AddToTable: ProcPtr);
  18. ;-------------------------------------------------------------------
  19.                 Seg         'TRes'
  20. EXPORT PROCEDURE CONVERTTOMENU(cmnuHandle:L, menuID:W, AddToTable:L)
  21.     BEGIN SAVE=d3-d7/a2-a4
  22.     
  23.             move.l    cmnuHandle(FP),a0    ;a0 <- cmnuHandle
  24.             move.l    (a0),a1
  25.             move.w    (a1),d7    ;d0 <- menuNumber
  26.             clr.l    d6
  27.             move.b    14(a1),d6    ;d6 <- length of menu title
  28.             move.l    a1,d2
  29.             add.l    #15,d6
  30.             add.l    d6,d2
  31.             move.l    d2,a3    ;a3 now pointing at first menu item
  32.             _GetHandleSize
  33.             _NewHandle        ;a0 <- hMENU
  34.             move.l    a0,d4    ;save it 
  35.             move.l    (a0),a1    ;a1 <- pMENU
  36.             move.l    a1,a4    ;save it
  37.             move.l    cmnuHandle(FP),a0
  38.             move.l    (a0),a0
  39.             move.l    d6,d0
  40.             _BlockMove        ;move menu header into MENU resource
  41.             add.l    d6,a4
  42.             move.w    #0,d5    ;init itemNumber
  43.             bra.s    endWhile
  44.     
  45. whileMoreItems
  46.             addq.w    #1,d5    ;bump itemNumber
  47.             add.l    #5,d6
  48.             move.l    a3,a0
  49.             move.l    a4,a1
  50.             move.l    d6,d0
  51.             _BlockMove        ;move menu item data sans command number
  52.             add.l    d6,a4
  53.             add.l    a3,d6
  54.             btst    #0,d6    ;test low order bit
  55.             beq.s    aligned
  56.             addq    #1,d6    ;align to next word
  57. aligned
  58.             move.l    d6,a3
  59.             move.w    (a3)+,d0
  60.             beq.s    endWhile
  61.             move.w    d0,-(sp)
  62.             move.w    d7,-(sp)
  63.             move.w    d5,-(sp)
  64.             move.l    AddToTable(FP),a0    
  65.             jsr    (a0)    ;jsr to AddToTable
  66. endWhile
  67.             clr.l    d6
  68.             move.b    (a3),d6
  69.             bne.s    whileMoreItems
  70.         
  71.             move.b    #0,(a4)+
  72.             move.l    a4,d0
  73.             move.l    d4,a0
  74.             sub.l    (a0),d0
  75.             _SetHandleSize
  76.             move.l    d4,-(sp)    ;push hMENU
  77.             move.l    #'MENU',-(sp)    
  78.             move.w    menuID(FP),-(sp)    ;push menuID
  79.             pea    NilStr
  80.             _AddResource
  81.             move.l    cmnuHandle(FP),-(sp)    ;push cmnuHandle
  82.             _RmveResource
  83.             move.l    cmnuHandle(FP),a0
  84.             _DisposHandle
  85.     
  86.             Return
  87. NilStr
  88.             DC.W    0
  89.             EndProc
  90.     END